package ssx.demo.ssxutils.multitask;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池
 */
public class MultiUtil {

    private static ExecutorService es = null;
    //类加载的时候执行此代码
    static {
//        System.out.println("类加载的时候执行此代码MultiUtil");
        es = Executors.newCachedThreadPool();
    }

    public static void startTask(Runnable runnable){
        if (null==runnable) return;
        System.out.println("当前线程池的信息："+es.toString().replace("java.util.concurrent.ThreadPoolExecutor",""));

        try {
            es.execute(runnable);
        }catch (Exception e){
            e.printStackTrace();
        }

    }

}
